iMacrosControlPlay Method

iMacros Component
Plays the specified macro code or path.

Namespace:  iMacros.Component
Assembly:  iMacros.Component (in iMacros.Component.dll) Version: 12.0.501.6698
Syntax

public int Play(
	string macroCodeOrPath
)

Parameters

macroCodeOrPath
Type: SystemString
The macro code (starting with the keyword "CODE:") or a full path to a file containing the macro. If IsPathRooted(String) returns false, iMacros will look for the file in the iMacros macros folder. The iMacros directories location can be set in the HKEY_CURRENT_USER\Software\Ipswitch\iMacros registry key. See the iMacros reference for the detailed values.

Return Value

Type: Int32
An int error code. A -99 return value means that the player is busy, either playing or paused.
Remarks

The caller should check this instance's current PlayerMode before calling this method. In case the player is not in Idle mode, Play(String) returns -99.
Examples

The example below assumes a Form with a Panel where to add the iMacros control and a play Button with a click event
using System;
using System.Windows.Forms;
using iMacros.Component;

public partial class MainForm : Form
{
    private iMacrosControl iim;

    public MainForm()
    {
        InitializeComponent();
        iim = iMacrosControl.Create("xxxx") // Use here the license key for iMacros.Component
        iim.Dock = DockStyle.Fill;
        browserPane.Controls.Add(iim);
    }
    private void play_Click(object sender, EventArgs e)
    {
        if (iim == null) 
            return;

        // Take care that the player is in idle mode before starting to play a macro
        if (iim.PlayerMode != PlaybackModes.Idle) 
            return;        

        string macro = "CODE:URL GOTO=http://www.imacros.net/ \nTAG POS=3 TYPE=A ATTR=CLASS:toplink";
        int res = iim.Play(macro);

        if (res == -99) // res == -99 means that the player was in playing mode when Play was called. 
            MessageBox.Show("Player is still playing");

        MessageBox.Show(String.Format("Play result is {0}", iim.ErrorText);
    }
}
See Also

Reference